﻿Imports Persistencia
Imports DSControlePadrao
Public Class ctrForma
    Inherits ctrPadrao

#Region "Variáveis"
    Private objFormaProposta As New perFormaProposta
#End Region

#Region "Enumerações"

    Public Enum eColunasForma
        COD_REGIAO = 0
        COD_PRODUTO = 1
        PRODUTO = 2
        FORMA = 3
        VALOR_FORMA = 4
        DILUIR = 5
    End Enum


#End Region

    Public Function retornarDatForma() As DataTable
        Dim datForma As New DataTable

        With datForma
            .Columns.Add("codRegiao", GetType(Integer))
            .Columns.Add("codProduto", GetType(String))
            .Columns.Add("produto", GetType(String))
            .Columns.Add("forma", GetType(String))
            .Columns.Add("valorForma", GetType(Double))
            .Columns.Add("diluir", GetType(Boolean))

            .TableName = "Formas"

        End With

        Return datForma

    End Function

    Public Function retornarValorForma(ByVal dValorForma As Decimal, ByVal dQuantidade As Double) As Decimal
        Dim dFormaIndividual As Decimal = 0

        Try

            dFormaIndividual = dValorForma / dQuantidade

            Return dFormaIndividual
        Catch ex As Exception

            Throw New Exception("Ocorreu um erro ao calcular o valor da fôrma. " & _
                                    Environment.NewLine & ex.Message)


        End Try
    End Function

    Public Function retornarFormaProposta(ByVal iCodProposta As Int32, ByVal iRevProposta As Int32) As DataTable
        Try

            Return objFormaProposta.retornarFormaProposta(iCodProposta, iRevProposta)

        Catch ex As Exception

            Throw New Exception("Ocorreu um erro no método retornarFormaProposta." & _
                                Environment.NewLine & ex.Message)

        End Try
    End Function


End Class
